package com.never.website.conttroler;

import java.security.Principal;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class LoginAdminController {
	private static final Logger logger = LoggerFactory.getLogger(LoginAdminController.class);
	
//	@RequestMapping(value = "/admin/login", method = RequestMethod.GET)
//	public String home(Locale locale, Model model) {
//		logger.info("Welcome login! The client locale is {}.", locale);
//		
//		return "admin/login";
//	}
	
	@RequestMapping(value="/admin/home", method = RequestMethod.GET)
	public String printWelcome(ModelMap model, Principal principal ) {
 
		String name = principal.getName();
		model.addAttribute("username", name);
		model.addAttribute("message", "Spring Security Custom Form example");
		return "admin/hello";
 
	}
 
	@RequestMapping(value="/admin/login", method = RequestMethod.GET)
	public String login(ModelMap model) {
		System.out.println("admin/login");
		return "admin/login";
 
	}
	
	@RequestMapping(value="/admin/loginfailed", method = RequestMethod.GET)
	public String loginerror(ModelMap model) {
 
		model.addAttribute("error", "true");
		return "admin/login";
 
	}
	
	@RequestMapping(value="/admin/logout", method = RequestMethod.GET)
	public String logout(ModelMap model) {
 
		return "admin/login";
 
	}
}
